package com.itheima.springbootwebtlias.service.impl;


import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.itheima.springbootwebtlias.mapper.LogMapper;
import com.itheima.springbootwebtlias.pojo.LogQueryParam;
import com.itheima.springbootwebtlias.pojo.OperateLog;
import com.itheima.springbootwebtlias.pojo.PageResult;
import com.itheima.springbootwebtlias.service.LogService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Slf4j
@Service
public class LogServiceImpl implements LogService {

    @Autowired
    private LogMapper  logMapper;

    //5.5 日志列表查询 分页查询
    @Override
    public PageResult queryLog(LogQueryParam logQueryParam) {
        //1.分页查询,启动分页插件
        PageHelper.startPage(logQueryParam.getPage(), logQueryParam.getPageSize());
        //2.执行查询
        Page<OperateLog> page =logMapper.queryLog(logQueryParam);

        //3.封装结果
        PageResult pageResult = new PageResult(page.getTotal(), page.getResult());

        return pageResult;

    }

}
